package Work;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        char[] chs = getContent();
        String checkCode = getCheckCode(chs);
        System.out.println("验证码为：" + checkCode);
    }

    public static String getCheckCode(char[] chs) {
        Random r = new Random();
        String checkCode = "";
        for (int i = 1; i <= 5 ; i++) {
            int randomIndex = r.nextInt(chs.length);
            checkCode += chs[randomIndex];
        }
        return checkCode;
    }

    public static char[] getContent() {
        char[] chs = new char[26+26+10];
        int index = 0;
        for (char c = 'a'; c <= 'z'; c++) {
            chs[index++] = c;
        }

        for (char c = 'A'; c < 'Z'; c++) {
            chs[index++] = c;
        }

        for(char c = '0';c <= 9;c++) {
            chs[index++] = c;
        }
        return chs;
    }

    public static void main5(String[] args) {
        Random random = new Random();
        int randomNum = random.nextInt(100) + 1;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你你要猜的数字：");
        int scNum = scanner.nextInt();
        if(scNum > randomNum) {
            System.out.println("猜打了");
        }
        else if(scNum < randomNum) {
            System.out.println("猜小了");
        }
        else {
            System.out.println("才对了");
        }
    }


    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入6个评委的打分：");
        int[] array = new int[6];
        for (int i = 0; i < array.length; i++) {
            System.out.println("请输入第" + (i+1) + "个评委的打分：");
           array[i] = scanner.nextInt();
        }

        int sum = 0;
        for (int i = 0; i < array.length; i++) {
            sum += array[i];
        }

        int max = array[0];
        for (int i = 1; i < array.length; i++) {
            if(array[i] > max) {
                max = array[i];
            }
        }

        int min = array[0];
        for (int i = 1; i < array.length; i++) {
            if(array[i] > min) {
                min = array[i];
            }
        }
        double avg = 0.0;
        avg = (sum - max - min) / (array.length - 2);
        System.out.println(avg);
    }


    public static void main3(String[] args) {
        int[] array = {11,22,33,44,55};
        for (int i = 0; i < array.length/2; i++) {
            int tmp = array[i];
            array[i] = array[array.length - 1 - i];
            array[array.length - 1 - i] = tmp;
        }
        System.out.println(Arrays.toString(array));
    }


    public static void main2(String[] args) {
        int[] array1 = {1,2,3};
        int[] array2 = {1,2,3};
        System.out.println(checkArrayContent(array1, array2));
    }

    public static boolean checkArrayContent(int[] array1,int[] array2) {
        if(array1.length != array1.length) {
            return false;
        }

        for (int i = 0; i < array1.length; i++) {
            if(array1[i] != array2[i]) {
                return false;
            }
        }
        return true;
    }


    public static void main1(String[] args) {
        int[] array = {78,45,99,23,45,12,9,45,99};
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要找的元素：");
        int num = scanner.nextInt();
        System.out.println(Arrays.toString(getIndex(num, array)));
    }

    public static int[] getIndex(int num, int[] array) {
        int con = 0;
        for (int i = 0; i < array.length; i++) {
            if(array[i] == num) {
                con++;
            }
        }

        int n = 0;
        int[] indexArray = new int[con];
        for (int i = 0; i < array.length; i++) {
            if(array[i] == num) {
                indexArray[n++] = i;
            }
        }
        return indexArray;
    }
}
